USE [master]
GO

-- Clear Existing Database and Files
IF EXISTS (SELECT * FROM sys.databases WHERE [Name]=N'%TargetDatabaseName%')
BEGIN
    DROP DATABASE [%TargetDatabaseName%]
END
GO

-- =============================================
-- Author:       Justin Wallace Saunders
-- Create date:  20090120
-- Description:  %TargetDatabaseName% Database
-- Information:  http://msdn.microsoft.com/en-us/library/ms190249.aspx
-- =============================================
CREATE DATABASE [%TargetDatabaseName%] ON PRIMARY
(
    NAME = N'%TargetDatabaseName%',
    FILENAME = N'%TargetDatabaseRoot%\%TargetDatabaseName%.mdf',
    SIZE = 4096KB,
    MAXSIZE = UNLIMITED,
    FILEGROWTH = 1024KB
)
LOG ON
(
    NAME = N'%TargetDatabaseName%_log',
    FILENAME = N'%TargetDatabaseRoot%\%TargetDatabaseName%_log.ldf',
    SIZE = 4096KB,
    MAXSIZE = 20480KB,
    FILEGROWTH = 1024KB
)
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
BEGIN
    EXECUTE [%TargetDatabaseName%].[dbo].[sp_fulltext_database] @action = 'enable'
END
GO

ALTER DATABASE [%TargetDatabaseName%] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET ANSI_PADDING OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET ANSI_NULL_DEFAULT OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET ANSI_NULLS OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET ANSI_WARNINGS ON
GO

ALTER DATABASE [%TargetDatabaseName%] SET ARITHABORT ON
GO

ALTER DATABASE [%TargetDatabaseName%] SET AUTO_CLOSE OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET AUTO_CREATE_STATISTICS ON
GO

ALTER DATABASE [%TargetDatabaseName%] SET AUTO_SHRINK OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET AUTO_UPDATE_STATISTICS ON
GO

ALTER DATABASE [%TargetDatabaseName%] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET CURSOR_CLOSE_ON_COMMIT OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET CURSOR_DEFAULT GLOBAL
GO

ALTER DATABASE [%TargetDatabaseName%] SET CONCAT_NULL_YIELDS_NULL OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET DATE_CORRELATION_OPTIMIZATION ON
GO

ALTER DATABASE [%TargetDatabaseName%] SET DB_CHAINING OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET DISABLE_BROKER
GO

ALTER DATABASE [%TargetDatabaseName%] SET MULTI_USER
GO

ALTER DATABASE [%TargetDatabaseName%] SET NUMERIC_ROUNDABORT OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET PAGE_VERIFY CHECKSUM
GO

ALTER DATABASE [%TargetDatabaseName%] SET PARAMETERIZATION SIMPLE
GO

ALTER DATABASE [%TargetDatabaseName%] SET QUOTED_IDENTIFIER OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET READ_COMMITTED_SNAPSHOT OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET READ_WRITE
GO

ALTER DATABASE [%TargetDatabaseName%] SET RECOVERY SIMPLE
GO

ALTER DATABASE [%TargetDatabaseName%] SET RECURSIVE_TRIGGERS OFF
GO

ALTER DATABASE [%TargetDatabaseName%] SET TRUSTWORTHY OFF
GO